package vo

import (
	"activity/infrastructure"
)

type Id struct {
	value int
	hd *infrastructure.HashId
}

var salt = "activity-salt-!@#$%^&*()"

func NewId() *Id {
	id := new(Id)
	id.hd = infrastructure.NewHashId(salt)
	return id
}

//Encode
func (id Id) Encode(value int) (string, error) {
	s, err := id.hd.Encode(value)
	return s, err
}

//Decode
func (id Id) Decode(data string) (int, error) {
	number, err := id.hd.DecodeFirst(data)
	return number, err
}

func (id *Id) Value() int {
	return id.value
}

func (id *Id) SetValue(value int) {
	id.value = value
}
